-- Viral Resistance - T-Engine 4 Module
-- Copyright (C) 2010 Mikolai Fajer
--
-- This program is free software: you can redistribute it and/or modify
-- it under the terms of the GNU General Public License as published by
-- the Free Software Foundation, either version 3 of the License, or
-- (at your option) any later version.
--
-- This program is distributed in the hope that it will be useful,
-- but WITHOUT ANY WARRANTY; without even the implied warranty of
-- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
-- GNU General Public License for more details.
--
-- You should have received a copy of the GNU General Public License
-- along with this program.  If not, see <http://www.gnu.org/licenses/>.
--
-- Mikolai Fajer "yufra"
-- mfajer@gmail.com

newChat{ id="first",
	text = [[#LIGHT_GREEN#A few of the cables appear to be severed here, with an occasional spark arcing across the gap.]],
	answers = {
		{"#LIGHT_BLUE#Look closer.", 
			cond=function(npc, player)
				return player:isQuestStatus("power_loss", engine.Quest.PENDING, "find_broken_conduit")
			end,
			jump="investigating",
		},
		{"#LIGHT_BLUE#Walk away."},
	}
}

newChat{ id="investigating",
	text = [[#LIGHT_GREEN#Everything appears to be in perfect working order.]],
	answers = {
		
		{"#LIGHT_BLUE#Walk away."},
	},
}

newChat{ id="investigate_off",
	text = [[#LIGHT_GREEN#One row of lights are blinking red.  The label next to that row reads "Conduit Current".]],
	answers = {
		{"#LIGHT_BLUE#Walk away.", action=function(npc, player)
			player:setQuestStatus("power_loss", engine.Quest.COMPLETED, "investigate")
			if not player:isQuestStatus("power_loss", engine.Quest.COMPLETED, "find_broken_conduit") then
				player:setQuestStatus("power_loss", engine.Quest.PENDING, "find_broken_conduit")
			end
			-- See if we already generated the spider zombie
			local spider_zombie = game.zone:makeEntityByName(game.level, "actor", "SPIDER_ZOMBIE")
			if spider_zombie then
				-- Find the spot to add the zombie
				local possible_spots = {}
				for i, v in pairs(game.level.spots) do
					if v.type == "spawn" and v.subtype == "SPIDER_ZOMBIE" then
						table.insert(possible_spots, v)
					end
				end
				local chosen_spot = assert(rng.table(possible_spots), "no spawn spots found!")
				game.zone:addEntity(game.level, spider_zombie, "actor", chosen_spot.x, chosen_spot.y)
				spider_zombie.ai_target.actor = player
			end
		end,
		},
	}
}

return "first"